package com.xca.znb.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class AccountDBHelper extends SQLiteOpenHelper {
    private static final String DATABASE_NAME = "account.db" ;
    private static final int DATABASE_VERSION = 1 ;
    public static final String TABLE_ACCOUNT =  "account" ;
    public static final String ACCOUNT_ID = "id" ;
    public static final String ACCOUNT_PHONE = "phone" ;
    public static final String ACCOUNT_NUM = "num" ;
    public static final String ACCOUNT_TYPE = "type" ;//账户类型有6种：充值(+)，提现(-)，购买(-)，退款(+)，出售(+)，买家退款(-)
    public static final String ACCOUNT_TIME_DAY = "time_day" ;
    public static final String ACCOUNT_TIME_SEC = "time_sec" ;

    private static final String CREATE_TABLE_ACCOUNT = "CREATE TABLE " + TABLE_ACCOUNT + " ( " +
            ACCOUNT_ID + " INTEGER PRIMARY KEY AUTOINCREMENT , " +
            ACCOUNT_PHONE + " TEXT NOT NULL , "  +
            ACCOUNT_NUM + " DOUBLE ," +
            ACCOUNT_TYPE + " TEXT NOT NULL , " +
            ACCOUNT_TIME_DAY + " TEXT , " +
            ACCOUNT_TIME_SEC + " TEXT ) ";


    public AccountDBHelper(@Nullable Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(CREATE_TABLE_ACCOUNT);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS " + TABLE_ACCOUNT);
        onCreate(db);
    }
}
